import request from '@/config/axios'

// 作业指导书 VO
export interface FileVO {
  id: number // 主键ID
  filename: string // 文件名
  path: string // 存放位置
  fileType: string // 类型
}

// 作业指导书 API
export const FileApi = {
  // 查询作业指导书分页
  getFilePage: async (params: any) => {
    return await request.get({ url: `/opticore/file/page`, params })
  },

  // 查询作业指导书详情
  getFile: async (id: number) => {
    return await request.get({ url: `/opticore/file/get?id=` + id })
  },

  // 新增作业指导书
  createFile: async (data: FileVO) => {
    return await request.post({ url: `/opticore/file/create`, data })
  },

  // 修改作业指导书
  updateFile: async (data: FileVO) => {
    return await request.put({ url: `/opticore/file/update`, data })
  },

  // 删除作业指导书
  deleteFile: async (id: number) => {
    return await request.delete({ url: `/opticore/file/delete?id=` + id })
  },

  // 下载作业指导书
  downloadForm: async (path: string) => {
    return await request.download({
      url: `/infra/file/download-local?path=${encodeURIComponent(path)}`
    });
  },
  // 导出作业指导书 Excel
  exportFile: async (params) => {
    return await request.download({ url: `/opticore/file/export-excel`, params })
  },
}
